package com.example.service.impl;

import com.example.mapper.CustomerMapper;
import com.example.pojo.Brand;
import com.example.pojo.Customer;
import com.example.pojo.PageBean;
import com.example.service.CustomerService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CustomerServiceImpl implements CustomerService {
    @Autowired
    private CustomerMapper customerMapper;

    @Override
    public PageBean getCustomer(Customer customer, Integer page, Integer pageSize) {
        //设置分页参数
        PageHelper.startPage(page,pageSize);
        List<Customer> list = customerMapper.getCustomer(customer);
        Page<Customer> p= (Page<Customer>) list;
        PageBean pageBean=new PageBean(p.getTotal(),p.getResult());
        return pageBean;
    }

    @Override
    public void deleteCustomer(String id) {
        customerMapper.deleteCustomer(id);
    }

    @Override
    public void updateCustomer(Customer customer) {
        customerMapper.updateCustomer(customer);
    }

    @Override
    public void addCustomer(Customer customer) {
        customerMapper.addCustomer(customer);
    }

    @Override
    public Customer login(Customer customer) {
        return customerMapper.login(customer);
    }

    @Override
    public Customer getCustomerById(Integer cusCode) {
        return customerMapper.getCustomerById(cusCode);
    }

}
